package com.fastadmin.config.security.simple;

import com.fastadmin.common.mapper.JsonMapper;
import com.fastadmin.controller.BaseController;
import com.google.common.collect.ImmutableMap;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author YangKun
 * @date 2019/4/3 23:05.
 */
public class LoginFailureHandler extends SimpleUrlAuthenticationFailureHandler {
    protected JsonMapper binder2 = JsonMapper.nonEmptyMapper();


    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
        response.sendRedirect("/login?error=用户名或者密码错误");
    }
}
